#include "Vertex.h"
#include "util/ByIdMatcher.h"

Vertex::Vertex(std::string id) {
	this->setId(id);
}

Vertex::~Vertex() {

}

bool Vertex::equals(Vertex* other) {
	ByIdMatcher<Vertex> matcher(this);
	return matcher.matches(other);
}

std::string Vertex::getId() {
	return this->id;
}

//double Vertex::getPositionX() {
//	return this->position_x;
//}
//
//double Vertex::setPositionX(double x) {
//	return this->position_x = x;
//}
//
//double Vertex::getPositionY() {
//	return this->position_y;
//}
//
//double Vertex::setPositionY(double y) {
//	return this->position_y = y;
//}

void Vertex::setId(std::string id) {
	this->id = id;
}

Vertex* Vertex::addOutgoingEdge(Edge* edge) throw (DuplicateElementException) {
	ByIdMatcher<Edge> matcher;
	if (this->outgoingEdges.contains(matcher.setCurrent(edge))) {
		throw(DuplicateElementException("El vertice \"" + this->getId()
				+ "\" ya contiene a la arista saliente \"" + edge->getId()
				+ "\"."));
	} else {
		this->outgoingEdges.append(edge);
	}
	return this;
}
Edge* Vertex::removeOutgoingEdge(Edge* edge) throw (util::ElementNotFoundException) {
	return this->outgoingEdges.remove(edge);
}

util::LinkedList<Edge> Vertex::getOutgoingEdges() {
	return this->outgoingEdges;
}
